home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 March / Pc Users extra 6.iso / pshare95 / prog / formula1 / vcform1.z / Accounts.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-09-17  |  30.0 KB  |  749 lines

  1. VERSION 5.00
  2. Object = "{13E51000-A52B-11D0-86DA-00608CB9FBFB}#5.0#0"; "VCF15.OCX"
  3. Begin VB.Form Accounts 
  4.    Caption         =   "Money Management"
  5.    ClientHeight    =   8370
  6.    ClientLeft      =   60
  7.    ClientTop       =   690
  8.    ClientWidth     =   10710
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   8370
  11.    ScaleWidth      =   10710
  12.    StartUpPosition =   2  'CenterScreen
  13.    Begin VB.Frame frmSheetName 
  14.       Caption         =   "Accounts"
  15.       BeginProperty Font 
  16.          Name            =   "Arial"
  17.          Size            =   14.25
  18.          Charset         =   0
  19.          Weight          =   700
  20.          Underline       =   0   'False
  21.          Italic          =   -1  'True
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   8175
  25.       Left            =   0
  26.       TabIndex        =   1
  27.       Top             =   0
  28.       Width           =   10590
  29.       Begin VB.CommandButton btnNewAccount 
  30.          BackColor       =   &H00808080&
  31.          Height          =   495
  32.          Left            =   90
  33.          Picture         =   "Accounts.frx":0000
  34.          Style           =   1  'Graphical
  35.          TabIndex        =   4
  36.          Top             =   360
  37.          Width           =   975
  38.       End
  39.       Begin VB.CommandButton btnEditAccount 
  40.          BackColor       =   &H00808080&
  41.          Height          =   495
  42.          Left            =   1200
  43.          Picture         =   "Accounts.frx":0952
  44.          Style           =   1  'Graphical
  45.          TabIndex        =   3
  46.          Top             =   360
  47.          Width           =   975
  48.       End
  49.       Begin VB.CommandButton btnDeleteAccount 
  50.          BackColor       =   &H00808080&
  51.          Height          =   495
  52.          Left            =   2280
  53.          Picture         =   "Accounts.frx":12A4
  54.          Style           =   1  'Graphical
  55.          TabIndex        =   2
  56.          Top             =   360
  57.          Width           =   975
  58.       End
  59.       Begin VCF150Ctl.F1Book F1Book1 
  60.          Height          =   7140
  61.          Left            =   120
  62.          TabIndex        =   0
  63.          Top             =   945
  64.          Width           =   10275
  65.          _ExtentX        =   18124
  66.          _ExtentY        =   12594
  67.          _0              =   $"Accounts.frx":1C62
  68.          _1              =   $"Accounts.frx":2067
  69.          _2              =   $"Accounts.frx":246C
  70.          _3              =   $"Accounts.frx":2871
  71.          _4              =   $"Accounts.frx":2C76
  72.          _5              =   $"Accounts.frx":307B
  73.          _6              =   $"Accounts.frx":3481
  74.          _7              =   $"Accounts.frx":3888
  75.          _8              =   $"Accounts.frx":3C8E
  76.          _9              =   $"Accounts.frx":4093
  77.          _10             =   $"Accounts.frx":4499
  78.          _11             =   $"Accounts.frx":489E
  79.          _12             =   $"Accounts.frx":4CA3
  80.          _13             =   $"Accounts.frx":50A8
  81.          _14             =   $"Accounts.frx":54AD
  82.          _15             =   $"Accounts.frx":58B2
  83.          _16             =   $"Accounts.frx":5CB8
  84.          _17             =   $"Accounts.frx":60BD
  85.          _18             =   $"Accounts.frx":64C2
  86.          _19             =   $"Accounts.frx":68C7
  87.          _20             =   $"Accounts.frx":6CCD
  88.          _21             =   $"Accounts.frx":70D2
  89.          _22             =   $"Accounts.frx":74D7
  90.          _23             =   $"Accounts.frx":78DC
  91.          _24             =   $"Accounts.frx":7CE1
  92.          _25             =   $"Accounts.frx":80E6
  93.          _26             =   $"Accounts.frx":84EC
  94.          _27             =   $"Accounts.frx":88F2
  95.          _28             =   $"Accounts.frx":8CF7
  96.          _29             =   $"Accounts.frx":90FC
  97.          _30             =   $"Accounts.frx":9501
  98.          _31             =   $"Accounts.frx":9906
  99.          _32             =   $"Accounts.frx":9D0B
  100.          _33             =   $"Accounts.frx":A110
  101.          _34             =   $"Accounts.frx":A515
  102.          _35             =   $"Accounts.frx":A91A
  103.          _36             =   $"Accounts.frx":AD1F
  104.          _37             =   $"Accounts.frx":B124
  105.          _38             =   $"Accounts.frx":B529
  106.          _39             =   $"Accounts.frx":B92E
  107.          _40             =   $"Accounts.frx":BD33
  108.          _41             =   $"Accounts.frx":C138
  109.          _42             =   $"Accounts.frx":C53D
  110.          _43             =   $"Accounts.frx":C943
  111.          _44             =   $"Accounts.frx":CD49
  112.          _45             =   $"Accounts.frx":D14E
  113.          _46             =   $"Accounts.frx":D554
  114.          _47             =   $"Accounts.frx":D959
  115.          _48             =   $"Accounts.frx":DD5F
  116.          _49             =   $"Accounts.frx":E164
  117.          _50             =   $"Accounts.frx":E569
  118.          _51             =   $"Accounts.frx":E96E
  119.          _52             =   $"Accounts.frx":ED74
  120.          _53             =   $"Accounts.frx":F179
  121.          _54             =   $"Accounts.frx":F57F
  122.          _55             =   $"Accounts.frx":F984
  123.          _56             =   $"Accounts.frx":FD89
  124.          _57             =   $"Accounts.frx":1018E
  125.          _58             =   $"Accounts.frx":10593
  126.          _59             =   $"Accounts.frx":10999
  127.          _60             =   $"Accounts.frx":10D9F
  128.          _61             =   $"Accounts.frx":111A4
  129.          _62             =   $"Accounts.frx":115A9
  130.          _63             =   $"Accounts.frx":119AE
  131.          _64             =   $"Accounts.frx":11DB3
  132.          _65             =   $"Accounts.frx":121B8
  133.          _66             =   $"Accounts.frx":125BE
  134.          _67             =   $"Accounts.frx":129C4
  135.          _68             =   $"Accounts.frx":12DC9
  136.          _69             =   $"Accounts.frx":131CE
  137.          _70             =   $"Accounts.frx":135D3
  138.          _71             =   $"Accounts.frx":139D8
  139.          _72             =   $"Accounts.frx":13DDD
  140.          _73             =   $"Accounts.frx":141E3
  141.          _74             =   $"Accounts.frx":145E8
  142.          _75             =   $"Accounts.frx":149ED
  143.          _76             =   $"Accounts.frx":14DF2
  144.          _77             =   $"Accounts.frx":151F7
  145.          _78             =   $"Accounts.frx":155FC
  146.          _79             =   $"Accounts.frx":15A01
  147.          _80             =   $"Accounts.frx":15E06
  148.          _81             =   $"Accounts.frx":1620B
  149.          _82             =   $"Accounts.frx":16610
  150.          _83             =   $"Accounts.frx":16A15
  151.          _84             =   $"Accounts.frx":16E1A
  152.          _85             =   $"Accounts.frx":1721F
  153.          _86             =   $"Accounts.frx":17624
  154.          _87             =   $"Accounts.frx":17A29
  155.          _88             =   $"Accounts.frx":17E2E
  156.          _89             =   $"Accounts.frx":18233
  157.          _90             =   $"Accounts.frx":18638
  158.          _91             =   $"Accounts.frx":18A3D
  159.          _92             =   $"Accounts.frx":18E42
  160.          _93             =   $"Accounts.frx":19247
  161.          _94             =   $"Accounts.frx":1964C
  162.          _95             =   $"Accounts.frx":19A51
  163.          _96             =   $"Accounts.frx":19E56
  164.          _97             =   $"Accounts.frx":1A25B
  165.          _98             =   $"Accounts.frx":1A660
  166.          _99             =   $"Accounts.frx":1AA65
  167.          _100            =   $"Accounts.frx":1AE6B
  168.          _101            =   $"Accounts.frx":1B270
  169.          _102            =   $"Accounts.frx":1B675
  170.          _103            =   $"Accounts.frx":1BA7A
  171.          _104            =   $"Accounts.frx":1BE7F
  172.          _105            =   $"Accounts.frx":1C285
  173.          _106            =   $"Accounts.frx":1C68A
  174.          _107            =   $"Accounts.frx":1CA8F
  175.          _108            =   $"Accounts.frx":1CE94
  176.          _109            =   $"Accounts.frx":1D29A
  177.          _110            =   $"Accounts.frx":1D69F
  178.          _111            =   $"Accounts.frx":1DAA4
  179.          _112            =   $"Accounts.frx":1DEA9
  180.          _113            =   $"Accounts.frx":1E2AE
  181.          _114            =   $"Accounts.frx":1E6B3
  182.          _115            =   $"Accounts.frx":1EAB8
  183.          _116            =   $"Accounts.frx":1EEBE
  184.          _117            =   $"Accounts.frx":1F2C3
  185.          _118            =   $"Accounts.frx":1F6C8
  186.          _119            =   $"Accounts.frx":1FACD
  187.          _120            =   $"Accounts.frx":1FED3
  188.          _121            =   $"Accounts.frx":202D8
  189.          _122            =   $"Accounts.frx":206DD
  190.          _123            =   $"Accounts.frx":20AE2
  191.          _124            =   $"Accounts.frx":20EE7
  192.          _125            =   $"Accounts.frx":212EC
  193.          _126            =   $"Accounts.frx":216F1
  194.          _127            =   $"Accounts.frx":21AF6
  195.          _128            =   $"Accounts.frx":21EFB
  196.          _129            =   $"Accounts.frx":22300
  197.          _130            =   $"Accounts.frx":22705
  198.          _131            =   $"Accounts.frx":22B0A
  199.          _132            =   $"Accounts.frx":22F0F
  200.          _133            =   $"Accounts.frx":23315
  201.          _134            =   $"Accounts.frx":2371A
  202.          _135            =   $"Accounts.frx":23B1F
  203.          _136            =   $"Accounts.frx":23F24
  204.          _137            =   $"Accounts.frx":24329
  205.          _138            =   $"Accounts.frx":2472E
  206.          _139            =   $"Accounts.frx":24B33
  207.          _140            =   $"Accounts.frx":24F38
  208.          _141            =   $"Accounts.frx":2533D
  209.          _142            =   $"Accounts.frx":25743
  210.          _143            =   $"Accounts.frx":25B48
  211.          _144            =   $"Accounts.frx":25F4D
  212.          _145            =   $"Accounts.frx":26353
  213.          _146            =   $"Accounts.frx":26759
  214.          _147            =   $"Accounts.frx":26B5E
  215.          _148            =   $"Accounts.frx":26F63
  216.          _149            =   $"Accounts.frx":27368
  217.          _150            =   $"Accounts.frx":2776D
  218.          _151            =   $"Accounts.frx":27B73
  219.          _152            =   $"Accounts.frx":27F77
  220.          _153            =   $"Accounts.frx":2837D
  221.          _154            =   $"Accounts.frx":28782
  222.          _155            =   $"Accounts.frx":28B87
  223.          _156            =   $"Accounts.frx":28F8C
  224.          _157            =   $"Accounts.frx":29391
  225.          _158            =   $"Accounts.frx":29796
  226.          _159            =   $"Accounts.frx":29B9B
  227.          _160            =   $"Accounts.frx":29FA0
  228.          _161            =   $"Accounts.frx":2A3A4
  229.          _162            =   $"Accounts.frx":2A7A9
  230.          _163            =   $"Accounts.frx":2ABAE
  231.          _164            =   $"Accounts.frx":2AFB3
  232.          _165            =   $"Accounts.frx":2B3B8
  233.          _166            =   $"Accounts.frx":2B7BC
  234.          _167            =   $"Accounts.frx":2BBC0
  235.          _168            =   $"Accounts.frx":2BFC5
  236.          _169            =   $"Accounts.frx":2C3C9
  237.          _170            =   $"Accounts.frx":2C7CD
  238.          _171            =   $"Accounts.frx":2CBD1
  239.          _172            =   $"Accounts.frx":2CFD6
  240.          _173            =   $"Accounts.frx":2D3DB
  241.          _174            =   $"Accounts.frx":2D7E1
  242.          _175            =   $"Accounts.frx":2DBE7
  243.          _176            =   $"Accounts.frx":2DFEC
  244.          _177            =   $"Accounts.frx":2E3F1
  245.          _178            =   $"Accounts.frx":2E7F6
  246.          _179            =   $"Accounts.frx":2EBFB
  247.          _180            =   $"Accounts.frx":2F000
  248.          _181            =   $"Accounts.frx":2F405
  249.          _182            =   $"Accounts.frx":2F80A
  250.          _183            =   $"Accounts.frx":2FC0F
  251.          _184            =   $"Accounts.frx":30014
  252.          _185            =   $"Accounts.frx":30419
  253.          _186            =   $"Accounts.frx":3081E
  254.          _187            =   $"Accounts.frx":30C23
  255.          _188            =   $"Accounts.frx":31028
  256.          _189            =   $"Accounts.frx":3142D
  257.          _190            =   $"Accounts.frx":31832
  258.          _191            =   $"Accounts.frx":31C37
  259.          _192            =   $"Accounts.frx":3203C
  260.          _193            =   $"Accounts.frx":32441
  261.          _194            =   $"Accounts.frx":32846
  262.          _195            =   $"Accounts.frx":32C4B
  263.          _196            =   $"Accounts.frx":33050
  264.          _197            =   $"Accounts.frx":33455
  265.          _198            =   $"Accounts.frx":3385A
  266.          _199            =   $"Accounts.frx":33C5F
  267.          _200            =   $"Accounts.frx":34064
  268.          _201            =   $"Accounts.frx":34469
  269.          _202            =   $"Accounts.frx":3486E
  270.          _203            =   $"Accounts.frx":34C73
  271.          _204            =   $"Accounts.frx":35078
  272.          _205            =   $"Accounts.frx":3547D
  273.          _206            =   $"Accounts.frx":35882
  274.          _207            =   $"Accounts.frx":35C87
  275.          _208            =   $"Accounts.frx":3608C
  276.          _209            =   $"Accounts.frx":36491
  277.          _210            =   $"Accounts.frx":36896
  278.          _211            =   $"Accounts.frx":36C9B
  279.          _212            =   $"Accounts.frx":370A0
  280.          _213            =   $"Accounts.frx":374A5
  281.          _214            =   $"Accounts.frx":378AA
  282.          _215            =   $"Accounts.frx":37CAF
  283.          _216            =   $"Accounts.frx":380B4
  284.          _217            =   $"Accounts.frx":384B9
  285.          _218            =   $"Accounts.frx":388BE
  286.          _219            =   $"Accounts.frx":38CC3
  287.          _220            =   $"Accounts.frx":390C8
  288.          _count          =   221
  289.          _ver            =   1
  290.       End
  291.    End
  292.    Begin VB.Menu mnuFile 
  293.       Caption         =   "&File"
  294.       Begin VB.Menu mnuFileNew 
  295.          Caption         =   "&New"
  296.       End
  297.       Begin VB.Menu mnuFileOpen 
  298.          Caption         =   "&Open"
  299.       End
  300.       Begin VB.Menu mnuFileSave 
  301.          Caption         =   "&Save"
  302.       End
  303.    End
  304. Attribute VB_Name = "Accounts"
  305. Attribute VB_GlobalNameSpace = False
  306. Attribute VB_Creatable = False
  307. Attribute VB_PredeclaredId = True
  308. Attribute VB_Exposed = False
  309. Dim PrevSheet As Integer
  310. Dim PrevRow As Long
  311. Dim PrevCol As Long
  312. Dim NumAccounts As Integer
  313. Dim NumCategories As Integer
  314. Dim hdrFormat As F1CellFormat
  315. Dim F1View As F1BookView
  316. Private Sub btnEditAccount_Click()
  317.     Dim AccountName As String
  318.     Dim pAccountName As String
  319.     pAccountName = F1Book1.TextRC(F1Book1.Row, 1)
  320.     AcctInfo.Show 1
  321.     AccountName = F1Book1.TextRC(F1Book1.Row, 1)
  322.     If AccountName <> pAccountName Then
  323.         While F1Book1.SheetName(F1Book1.Sheet) <> pAccountName
  324.             F1Book1.Sheet = F1Book1.Sheet + 1
  325.         Wend
  326.         
  327.         F1Book1.SheetName(F1Book1.Sheet) = AccountName
  328.         F1Book1.Sheet = 1
  329.     End If
  330. End Sub
  331. Private Sub btnNewAccount_Click()
  332.     Dim AccountName As String
  333.     Dim x As Integer
  334.     Dim y As Integer
  335.     If F1Book1.SheetName(F1Book1.Sheet) = "Accounts" Then
  336.         F1Book1.SetFocus
  337. '        F1View.ShowSelections = F1Off
  338.         
  339.         F1Book1.Row = NumAccounts + 1
  340.         F1Book1.Col = 1
  341.         AcctInfo.Show 1
  342.                 
  343.         AccountName = F1Book1.TextRC(F1Book1.Row, 1)
  344.         Call AddAccountSheet(AccountName)
  345.         F1View.FormulaSRC(1, F1View.Row, 4) = "COUNT(" & AccountName & "!A3:A100)"
  346.         F1View.FormulaSRC(1, F1View.Row, 5) = AccountName & "!H99"
  347.         F1View.Sheet = 2
  348. '        F1View.ShowSelections = F1Off
  349.         
  350.         F1View.Col = NumAccounts + 4
  351.         F1View.Row = 2
  352.         F1View.Formula = "Accounts!A" & NumAccounts + 1
  353.         F1View.SetFont "Arial", 8, True, True, False, False, 0, False, False
  354.         F1View.Row = 3
  355.         F1View.Formula = "SUMIF(" & AccountName & "!$I$3:$I$100,$B3," & AccountName & "!$G$2:$G$99)-SUMIF(" & AccountName & "!$I$3:$I$100,$B3," & AccountName & "!$E$2:$E$99)"
  356.         F1View.SetSelection 3, F1View.Col, NumCategories + 2, F1View.Col
  357.         F1View.EditCopyDown
  358.         F1View.SetBorder -1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0
  359.         F1View.ShowSelections = F1Auto
  360.         
  361.         F1View.SetSelection 3, F1View.Col, NumCategories + 2, F1View.Col
  362.         F1View.FormulaRC(NumCategories + 4, F1View.Col) = "Sum(" & F1View.Selection & ")"
  363.         F1View.SetSelection 1, 1, 1, 1
  364.         
  365.         F1View.Sheet = 3
  366.         y = 0
  367.         For x = 1 To 12
  368.             y = y + 3 + NumAccounts
  369.             F1View.Col = y
  370.             F1View.InsertRange 1, F1View.Col, 1, F1View.Col, F1ShiftCols + F1FixupAppend
  371.             F1View.ColHidden(F1View.Col) = True
  372.             F1View.Row = 3
  373.             F1View.Formula = "SUMIF(" & AccountName & "!$I$3:$I$100,B3," & AccountName & "!$G$2:$G$99)-SUMIF(" & AccountName & "!$I$3:$I$100,B3," & AccountName & "!$E$2:$E$99)"
  374.             F1View.SetSelection 3, F1View.Col, NumCategories + 2, F1View.Col
  375.             F1View.EditCopyDown
  376.             y = y + 1
  377.         Next x
  378.             
  379.         F1View.Sheet = 1
  380. '        F1View.ShowSelections = F1Auto
  381.         NumAccounts = NumAccounts + 1
  382.     End If
  383.     If F1Book1.SheetName(F1Book1.Sheet) = "Category Summary" Then
  384.         
  385.         F1Book1.Row = NumCategories + 3
  386.         F1Book1.Col = 1
  387.         F1View.EnableProtection = False
  388.         F1View.InsertRange F1View.Row, 1, F1View.Row, 1, F1ShiftRows + F1FixupAppend
  389. '        F1Book1.InsertDlg
  390.         F1View.SetSelection F1View.Row - 1, 2, F1View.Row, F1View.LastCol
  391.         F1View.EditCopyDown
  392.         
  393.         F1View.Row = F1View.Row + 1
  394.         F1View.Col = 1
  395.         F1Book1.StartEdit False, False, False
  396.         F1Book1.SetFocus
  397.         F1View.EnableProtection = True
  398.                 
  399.         NumCategories = NumCategories + 1
  400.         
  401.     End If
  402. End Sub
  403. Private Sub F1Book1_DblClick(ByVal nRow As Long, ByVal nCol As Long)
  404.     Dim fnd As String
  405.     Dim acct As String
  406.     Dim pFound As Long
  407.     F1Book1.Repaint = False
  408.     If F1Book1.SheetName(F1Book1.Sheet) = "Accounts" Then
  409.         If nRow = 0 Then
  410.             F1Book1.Sort 1, 1, NumAccounts, 256, True, 1
  411.         Else
  412.             While F1Book1.SheetName(F1Book1.Sheet) <> F1Book1.TextSRC(1, nRow, 1)
  413.                 F1Book1.Sheet = F1Book1.Sheet + 1
  414.             Wend
  415.         End If
  416.     ElseIf F1Book1.SheetName(F1Book1.Sheet) <> "Category Summary" Then
  417.         F1Book1.StartEdit False, True, False
  418.     End If
  419.     If F1Book1.SheetName(F1Book1.Sheet) = "Category Summary" And F1Book1.Row > 1 And F1Book1.Col > 2 Then
  420.         fnd = Abs(F1Book1.Number)
  421.         acct = F1Book1.TextRC(1, nCol)
  422.         While F1Book1.SheetName(F1Book1.Sheet) <> acct
  423.             F1Book1.Sheet = F1Book1.Sheet + 1
  424.         Wend
  425.     ElseIf (F1Book1.SheetName(F1Book1.Sheet) = "Category Summary" Or F1Book1.SheetName(F1Book1.Sheet) = "Budget") And F1Book1.Row < 3 Then
  426.         F1Book1.Sort 3, 1, NumCategories + 2, 256, True, 1
  427.     End If
  428.     F1Book1.Repaint = True
  429. End Sub
  430. Private Sub F1Book1_EndEdit(EditString As String, Cancel As Integer)
  431.     Dim InsertRow As Long
  432.     Dim Category As String
  433.     If F1Book1.SheetName(F1Book1.Sheet) = "Category Summary" Then
  434.         Call FillCombo
  435.         F1Book1.Sheet = 2
  436.         Category = F1Book1.Text
  437.         InsertRow = F1Book1.Row
  438.         F1Book1.Sheet = 3
  439.         F1Book1.Row = InsertRow
  440.         F1Book1.InsertRange F1Book1.Row, 1, F1Book1.Row, 1, F1ShiftRows + F1FixupAppend
  441.         F1Book1.Col = 1
  442.         F1Book1.Text = Category
  443.         F1Book1.SetSelection F1Book1.Row - 1, 2, F1Book1.Row, 256
  444.         F1Book1.EditCopyDown
  445.         F1Book1.Sheet = 2
  446.     End If
  447. End Sub
  448. Private Sub F1Book1_SelChange()
  449.     Dim pLocked As Boolean
  450.     Dim pHidden As Boolean
  451.     Dim objID As Long
  452.     Dim pX1 As Single
  453.     Dim pY1 As Single
  454.     Dim pX2 As Single
  455.     Dim pY2 As Single
  456.     F1Book1.Repaint = False
  457.     If F1Book1.SheetName(F1Book1.Sheet) = "" Then
  458.         F1Book1.Sheet = PrevSheet
  459.         Exit Sub
  460.     End If
  461.     If F1Book1.Sheet <> PrevSheet Then
  462.         frmSheetName.Caption = F1Book1.SheetName(F1Book1.Sheet)
  463.     End If
  464.     If (F1Book1.SheetName(F1Book1.Sheet) = "Budget") Then
  465.         btnNewAccount.Enabled = False
  466.         btnEditAccount.Enabled = False
  467.         btnDeleteAccount.Enabled = False
  468.     Else
  469.         btnNewAccount.Enabled = True
  470.         btnEditAccount.Enabled = True
  471.         btnDeleteAccount.Enabled = True
  472.     End If
  473.     If (F1Book1.SheetName(F1Book1.Sheet) <> "Accounts") And (F1Book1.SheetName(F1Book1.Sheet) <> "Category Summary") And (F1Book1.SheetName(F1Book1.Sheet) <> "Budget") Then
  474.         F1Book1.GetProtection pLocked, pHidden
  475.         If pLocked Then
  476.             F1Book1.Row = PrevRow
  477.             F1Book1.Col = PrevCol
  478.         End If
  479.         
  480.         If F1Book1.Row Mod 2 = 1 Then
  481.             objID = F1Book1.ObjNameToID("chkCleared")
  482.             F1Book1.ObjGetPos objID, pX1, pY1, pX2, pY2
  483.             F1Book1.ObjSetPos objID, pX1, F1Book1.Row - 1 + 0.21875, pX2, F1Book1.Row - 0.175781
  484.             If F1Book1.TextRC(F1Book1.Row, 6) = "X" Then
  485.                 F1Book1.ObjValue(objID) = 1
  486.             Else
  487.                 F1Book1.ObjValue(objID) = 0
  488.             End If
  489.         Else
  490.             objID = F1Book1.ObjNameToID("chkCleared")
  491.             F1Book1.ObjGetPos objID, pX1, pY1, pX2, pY2
  492.             F1Book1.ObjSetPos objID, pX1, F1Book1.Row - 2 + 0.21875, pX2, F1Book1.Row - 1 - 0.175781
  493.             If F1Book1.TextRC(F1Book1.Row - 1, 6) = "X" Then
  494.                 F1Book1.ObjValue(objID) = 1
  495.             Else
  496.                 F1Book1.ObjValue(objID) = 0
  497.             End If
  498.         End If
  499.         
  500.         If (F1Book1.TextRC(2, F1Book1.Col) = "Category") And (F1Book1.Row Mod 2 = 0) Then
  501.             objID = F1Book1.ObjNameToID("cboCategories")
  502.             F1Book1.ObjGetPos objID, pX1, pY1, pX2, pY2
  503.             F1Book1.ObjSetPos objID, pX1, F1Book1.Row - 1, pX2, F1Book1.Row + 15
  504.             F1Book1.ObjSetCell objID, 2, F1Book1.Row, 3
  505.             F1Book1.ObjVisible(objID) = True
  506.         
  507.             F1Book1.Recalc
  508.         Else
  509.             objID = F1Book1.ObjNameToID("cboCategories")
  510.             F1Book1.ObjVisible(objID) = False
  511.         End If
  512.     End If
  513.     PrevSheet = F1Book1.Sheet
  514.     PrevRow = F1Book1.Row
  515.     PrevCol = F1Book1.Col
  516.     F1Book1.Repaint = True
  517. End Sub
  518. Private Sub F1Book1_StartEdit(EditString As String, Cancel As Integer)
  519.     If (F1Book1.SheetName(F1Book1.Sheet) <> "Accounts") And (F1Book1.SheetName(F1Book1.Sheet) <> "Category Summary") Then
  520.         
  521. '        If F1Book1.TextRC(1, F1Book1.Col) = "Date" Then
  522. '            EditString = Date
  523. '        End If
  524.         
  525.         If F1Book1.TextRC(1, F1Book1.Col) = "Clr" Then
  526.             Cancel = True
  527.             If F1Book1.ObjValue(F1Book1.ObjNameToID("chkCleared")) = 1 Then
  528.                 F1Book1.ObjValue(F1Book1.ObjNameToID("chkCleared")) = 0
  529.                 F1Book1.TextRC(F1Book1.Row, F1Book1.Col) = ""
  530.             Else
  531.                 F1Book1.ObjValue(F1Book1.ObjNameToID("chkCleared")) = 1
  532.                 F1Book1.TextRC(F1Book1.Row, F1Book1.Col) = "X"
  533.             End If
  534.             Exit Sub
  535.         End If
  536.         
  537.         If (F1Book1.TextRC(2, F1Book1.Col) = "Category") And (F1Book1.Row Mod 2 = 0) Then
  538.             Cancel = True
  539.             Exit Sub
  540.         End If
  541.     End If
  542. End Sub
  543. Private Sub F1Book1_TopLeftChanged()
  544.     If F1Book1.SheetName(F1Book1.Sheet) <> "Accounts" And F1Book1.SheetName(F1Book1.Sheet) <> "Category Summary" Then
  545.         If (F1Book1.TopRow Mod 2) = 0 Then
  546.             F1Book1.TopRow = F1Book1.TopRow + 1
  547.         End If
  548.     End If
  549. End Sub
  550. Private Sub Form_Load()
  551.     NumAccounts = 2
  552.     NumCategories = 19
  553.     Call CreateCellFormats
  554.     Set F1View = F1Book1.CreateBookView
  555.         
  556.     Call FillCombo
  557.     F1Book1.Sheet = 1
  558.     F1View.Sheet = 1
  559.     frmSheetName.Caption = "Accounts"
  560. End Sub
  561. Private Sub mnuFileNew_Click()
  562.     Dim ftype As F1FileTypeConstants
  563.     On Error GoTo mnuFileNewError
  564.     ftype = F1Book1.ReadEx("Accounts.Vts")
  565.     F1Book1.ShowEditBar = False
  566.     Call FillCombo
  567.     Exit Sub
  568. mnuFileNewError:
  569.     If Err <> 20023 Then
  570.         MsgBox "Error loading template file!"
  571.     End If
  572. End Sub
  573. Private Sub mnuFileOpen_Click()
  574.     Dim fname As String
  575.     Dim ftype As F1FileTypeConstants
  576.     On Error GoTo mnuFileOpenError
  577.     fname = F1Book1.OpenFileDlgEx("Open Account", F1Book1.hWnd)
  578.     ftype = F1Book1.ReadEx(fname)
  579.     F1Book1.ShowEditBar = False
  580.     Call FillCombo
  581.     Exit Sub
  582. mnuFileOpenError:
  583.     If Err <> 20023 Then
  584.         MsgBox "Error loading file!"
  585.     End If
  586. End Sub
  587. Private Sub mnuFileSave_Click()
  588.     Dim pFileSpec As New F1FileSpec
  589.         
  590.     On Error GoTo mnuFileSaveError
  591.     F1Book1.SaveFileDlgEx "Save Account", pFileSpec
  592.     F1Book1.WriteEx pFileSpec.Name, pFileSpec.Type
  593.     Exit Sub
  594. mnuFileSaveError:
  595.     If Err <> 20023 Then
  596.         MsgBox "Error saving file!"
  597.     End If
  598. End Sub
  599. Public Sub FillCombo()
  600.     Dim objID As Long
  601.     Dim nSheet As Long
  602.     Dim nRow As Long
  603.     Dim nCol As Long
  604.     Dim cboItem As String
  605.     Dim nSheets As Integer
  606.            
  607.     PrevSheet = 1
  608.     PrevRow = 1
  609.     PrevCol = 1
  610. '    F1View.DoEndEdit = False
  611.     For nSheets = 4 To F1View.NumSheets - 1
  612.         F1View.Sheet = nSheets
  613.         objID = F1View.ObjNameToID("cboCategories")
  614.         
  615.         nRow = 3
  616.         cboItem = F1View.TextSRC(2, nRow, 1)
  617.         
  618.         While cboItem <> ""
  619.             F1View.ObjAddItem objID, cboItem
  620.             nRow = nRow + 1
  621.             cboItem = F1View.TextSRC(2, nRow, 1)
  622.         Wend
  623.         
  624.         F1View.ObjVisible(objID) = False
  625.     Next nSheets
  626. '    F1View.DoEndEdit = True
  627. End Sub
  628. Public Sub AddAccountSheet(SheetName As String)
  629.     Dim pID As Long
  630.     Dim x As Integer
  631. '    F1View.DoSelChange = False
  632.        
  633.     F1View.InsertSheets F1View.NumSheets, 1
  634.     F1View.SheetName(F1View.NumSheets - 1) = SheetName
  635.         
  636.     F1View.Sheet = F1View.NumSheets - 1
  637. '    F1View.ShowSelections = F1Off
  638.     F1View.ShowGridLines = False
  639.     F1View.ShowColHeading = False
  640.     F1View.ShowRowHeading = False
  641.     F1View.MaxCol = 9
  642.     F1View.MaxRow = 100
  643.     F1View.FixedRow = 1
  644.     F1View.FixedRows = 2
  645.     F1View.ObjNew F1ObjDropDown, 2, 2, 3, 3, pID
  646.     F1View.ObjName(pID) = "cboCategories"
  647.     Call FillCombo
  648.     F1View.ObjNew F1ObjCheckBox, 5.227539, 2.234375, 5.772461, 2.882813, pID
  649.     F1View.ObjName(pID) = "chkCleared"
  650.             
  651.     F1View.SetSelection 1, 1, 1, 3
  652.     F1View.AddSelection 1, 4, 1, 8
  653.     F1View.AddSelection 2, 1, 2, 8
  654.     F1View.SetCellFormat hdrFormat
  655.             
  656. ' Temporary workaround for bug with Cell Format of FontName
  657.     F1View.SetFont "Arial", 8, True, True, False, False, 0, False, False
  658.     F1View.SetSelection 3, -1, 15, -1
  659.     F1View.SetProtection False, False
  660.                 
  661.     F1View.SetSelection 3, 1, 100, 8
  662.     F1View.SetBorder -1, 1, 1, -1, 1, 0, 0, 0, 0, 0, 0
  663.     F1View.SetFont "Arial", 8, False, False, False, False, 0, False, False
  664.     For x = 3 To 100
  665.         If x Mod 2 = 1 Then
  666.             F1View.SetSelection x, 1, x, 8
  667.             F1View.SetBorder -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0
  668.             F1View.SetSelection x, 4, x, 4
  669.             F1View.SetBorder -1, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0
  670.             F1View.SetSelection x, 3, x, 3
  671.             F1View.SetBorder -1, -1, 0, -1, -1, 0, 0, 0, 0, 0, 0
  672.             F1View.SetSelection x, 8, x, 8
  673.             F1View.SetProtection True, False
  674.             If x = 3 Then
  675.                 F1View.Formula = "G3-E3"
  676.             Else
  677.                 F1View.Formula = "H" & x - 2 & "-E" & x & "+G" & x
  678.             End If
  679.         Else
  680.             F1View.SetSelection x, 1, x, 2
  681.             F1View.AddSelection x, 5, x, 8
  682.             F1View.SetPattern 2, 0, RGB(51, 204, 204)
  683.             F1View.SetProtection True, False
  684.             F1View.SetSelection x, 3, x, 4
  685.             F1View.SetPattern 1, RGB(51, 204, 204), RGB(51, 204, 204)
  686.         End If
  687.     Next x
  688.     F1View.SetSelection -1, 5, -1, 5
  689.     F1View.AddSelection -1, 7, -1, 7
  690.     F1View.AddSelection -1, 8, -1, 8
  691.     F1View.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
  692.     F1View.ColWidthUnits = F1ColWidthUnitsCharacters
  693.     F1View.ColWidth(1) = 7.715 * 256
  694.     F1View.ColWidth(2) = 6.285 * 256
  695.     F1View.ColWidth(3) = 22.29 * 256
  696.     F1View.ColWidth(4) = 20.57 * 256
  697.     F1View.ColWidth(5) = 10.43 * 256
  698.     F1View.ColWidth(6) = 3.145 * 256
  699.     F1View.ColWidth(7) = 10.43 * 256
  700.     F1View.ColWidth(8) = 10.43 * 256
  701.     F1View.TextRC(1, 1) = "Date"
  702.     F1View.TextRC(1, 2) = "Ref"
  703.     F1View.TextRC(1, 3) = "Payee"
  704.     F1View.TextRC(1, 6) = "Clr"
  705.     F1View.TextRC(1, 8) = "Balance"
  706.     F1View.TextRC(2, 3) = "Category"
  707.     F1View.TextRC(2, 4) = "Memo"
  708.     If F1View.TextSRC(1, NumAccounts + 1, 2) = "CCard" Then
  709.         F1View.TextRC(1, 5) = "Charge"
  710.         F1View.TextRC(1, 7) = "Payment"
  711.     Else
  712.         F1View.TextRC(1, 5) = "Payment"
  713.         F1View.TextRC(1, 7) = "Deposit"
  714.     End If
  715.     Dim formulatext As String
  716.     formulatext = "TEXT(A3," & """" & "mmmm" & """" & ")&YEAR(A3)&C4"
  717.     F1View.FormulaSRC(NumAccounts + 4, 4, 9) = formulatext
  718.     F1View.SetSelection 4, 9, 100, 9
  719.     F1View.EditCopyDown
  720.     F1View.ColHidden(9) = True
  721.     F1View.EnableProtection = True
  722.     F1View.SetSelection 3, 1, 3, 1
  723. '    F1View.ShowSelections = F1On
  724. '    F1View.DoSelChange = True
  725. End Sub
  726. Public Sub CreateCellFormats()
  727.     Set hdrFormat = F1Book1.CreateNewCellFormat
  728.     With hdrFormat
  729.         .FontName = "Arial"
  730.         .FontSize = 8
  731.         .FontBold = True
  732.         .FontItalic = True
  733.         
  734.         .PatternStyle = 1
  735.         .PatternFG = RGB(51, 204, 204)
  736.         
  737.         .ProtectionLocked = True
  738.         
  739.         .BorderColor(F1BottomBorder) = 0
  740.         .BorderColor(F1TopBorder) = 0
  741.         .BorderColor(F1HInsideBorder) = 0
  742.         .BorderColor(F1VInsideBorder) = 0
  743.         .BorderStyle(F1BottomBorder) = F1BorderThick
  744.         .BorderStyle(F1TopBorder) = F1BorderThin
  745.         .BorderStyle(F1HInsideBorder) = F1BorderThin
  746.         .BorderStyle(F1VInsideBorder) = F1BorderThin
  747.     End With
  748. End Sub
  749.